package models

import (
	_ "github.com/go-sql-driver/mysql"
	"github.com/astaxie/beego/orm"
)

// Model Struct
type User struct {
	Id   int  //'orm:pk,auto'
	Name string `orm:"size(100)"` //varchar(100)

	User_order []*User_order `orm:"reverse(many)"` //设置一对多
}

type User_order struct{
	Id int
	Order_data string `orm:size(100)`

	User *User `orm:"rel(fk)"` //反向多对一
}

func init(){
	// set default database
	orm.RegisterDataBase("default", "mysql", "shdkpa:upd5dp2k@tcp(sql.v113.vhostgo.com:3306)/shdkpa?charset=utf8", 30)

	// register model
	orm.RegisterModel(new(User),new(User_order))

	// create table
	orm.RunSyncdb("default", false, true)
}
